import { Link } from 'react-router-dom'

import './index.less'

export class List extends React.Component {
    constructor(props) {
        super(props);
    }

    render() {
        let isList = this.props.isList ? this.props.isList : false;
        let list = this.props.goodsList.map(({ id, listImg, title, price, num, factory }) => {
            return (
                <li key={id}>
                    <Link to={isList ? `/detail/${id}` : `/goods`}>
                        <div className="top">
                            <img src={listImg} alt="" />
                        </div>
                        <div className="bot">
                            <p className="title">{title}</p>
                            <div>
                                <span>¥ {price}</span>
                                <s>销量：<i>{num}</i></s>
                            </div>
                        </div>
                    </Link>
                </li>
            );
        });

        return (
            <div className="list w1000">
                <ul className="clearfix w1000">{list}</ul>
            </div>
        )
    }
}